package uniLearn.data;

public class AssignmentMaterial {
	//define
	//public static final int ID_MAX_LENGTH = 10;
	public static final int NAME_MAX_LENGTH = 50;
	public static final int FILENAME_MAX_LENGTH = 50;
	
	private int id;
	private String name;
	private int acId;
	private String fileName;
	private String info;
	
	//constructor
	public AssignmentMaterial(int id, String name, int acId) {
		this.setName(name);
		this.id = id;
		this.acId = acId;
	}

	//get method
	public int getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public int getACId() {
		return acId;
	}

	public String getFileName() {
		return fileName;
	}

	public String getInfo() {
		return info;
	}

	//set method
	public void setName(String name) {
		if(name.isEmpty() || name.length() > NAME_MAX_LENGTH) {
			//error
			return;
		}
		this.name = name;
	}

	public void setFileName(String fileName) {
		if(fileName.length() > FILENAME_MAX_LENGTH) {
			//error
			return;
		}
		this.fileName = fileName;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	//override
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + acId;
		result = prime * result
				+ ((fileName == null) ? 0 : fileName.hashCode());
		result = prime * result + id;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AssignmentMaterial other = (AssignmentMaterial) obj;
		if (acId != other.acId)
			return false;
		if (fileName == null) {
			if (other.fileName != null)
				return false;
		} else if (!fileName.equals(other.fileName))
			return false;
		if (id != other.id)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "AssignmentMaterial [id=" + id + ", name=" + name + ", acId="
				+ acId + ", fileName=" + fileName + "]";
	}
}
